package com.loan.system.domain.work.domain;

import com.loan.system.create.domain.AssistPdfSearchWxBase;
import lombok.Data;

/**
 * packageName com.loan.system.domain.work.domain
 *
 * @author Sophia
 * @className WxPdfDomain
 * @description TODO
 * @date 2025/4/22
 */
@Data
public class WxPdfDomain {

    /**
     * 交易日期
     */
    private String transactionDate;

    /**
     * 交易时间
     */
    private String transactionTime;
    /**
     * 交易摘要
     */
    private String transactionSummary;

    /**
     * 交易金额
     */
    private String transactionAmount;

    /**
     * 本次余额
     */
    private String currentBalance;

    /**
     * 交易类型
     */
    private String transactionType;

    /**
     * 对手信息
     */
    private String oppositionInformation;

    /**
     * 日志号
     */
    private String logNo;

    /**
     * 交易渠道
     */
    private String transactionChannels;

    /**
     * 交易附言
     */
    private String transactionNote;

    /**
     * 序号
     */
    private Integer sortNo;

    // Integet类型交易金额
    private Integer transactionMoneyInt;
    // 金额小数点后数字
    private String afterNum;


    public WxPdfDomain() {
    }

    public WxPdfDomain(AssistPdfSearchWxBase base, Integer sortNo) {
        // 交易单号
        this.transactionSummary = base.getWxBaseTransactionOrder();
        // 交易类型
        this.transactionType = base.getWxBaseTransactionType();
        this.transactionChannels = base.getWxBaseTransactionTypeDesc();
        // 收支其他
        this.logNo = base.getWxBaseTransactionInoutType();
        // 交易方式
        this.currentBalance = base.getWxBaseTransactionWay();
        // 金额
        this.transactionAmount = base.getWxBaseTransactionType() + String.valueOf(base.getWxBaseTransactionAmount());
        this.transactionMoneyInt = base.getWxBaseTransactionAmount().intValue();
        // 交易对方
        this.oppositionInformation = base.getWxBaseTransactionTradeName();
        // 商户单号
        this.transactionNote = base.getWxBaseTransactionTradeOrder();

        this.sortNo = sortNo;
        this.afterNum = (this.transactionAmount.contains(".") && this.transactionAmount.length() > 3) ? this.transactionAmount.substring(this.transactionAmount.length() - 3) : ".00";
    }

    /**
     * 获取修改并重组后的金额值
     *
     * @return
     */
    public String getDealAmount() {
        return String.format("%s%s%s", this.getTransactionType(), this.getTransactionMoneyInt(), this.getAfterNum());
    }

}
